package com.wuxiaofan.api;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.fastjson.JSONObject;
import com.wuxiaofan.service.OrderInfoService;
import com.wuxiaofan.vo.ReturnResult;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("orderInfo")
public class OrderInfoController {
    @Autowired
    private OrderInfoService orderInfoService;

    @GlobalTransactional
    @SentinelResource
    @RequestMapping("addOrder")
    public ReturnResult addOrder(@RequestBody JSONObject jsonObject) throws Exception{
        orderInfoService.save(jsonObject);
        return ReturnResult.success("下单成功!");
    }
}
